<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ taglib prefix="form" uri="http://www.springframework.org/tags/form" %>
<%@ taglib uri="/WEB-INF/html.tld" prefix="html" %>
<%@ taglib prefix="spring" uri="http://www.springframework.org/tags"%>

<c:url var="financialForm" value="${util.en('/finance/miniForm')}" />
<c:url var="rateCardUrl" value="${util.en('/finance/ratecard/input')}"/>
<c:url var="rateBandUrl" value="${util.en('/finance/rateband/input')}"/>
<c:url var="financialCalculator" value="${util.en('/finance/calculator')}" />

<div class="window">
	<div class="window-holder">
		<h4 class="window-header-title"><span>Add Financial Product</span></h4>
		<div class="window-content">
			<div class="breadcrumb green">
				<a href="javascript:_loadContent('${financialForm}','financialProduct')" class="active">Financial Product</a>
				<a href="javascript:_loadContent('${rateCardUrl}','financialProduct')">Rate Card</a>
				<a href="javascript:_loadContent('${rateBandUrl}','financialProduct')">Rate Band</a>
				<a href="javascript:_loadContent('${financialCalculator}','financialProduct')">Check Calculation</a>
				
			</div>
			<div id="window-content-holder">
				<jsp:include page="financialForm.jsp"></jsp:include>
			</div>
		</div>
		<div class="window-footer-title">
		<div class="button-holder">
			<button type="button" id="addFinancial">Submit</button>
		</div>
	</div>
	</div>
</div>
	
 
<script type="text/javascript">

$(function () {
	
	$("#addFinancial").on("click",addFinanciealProduct);  
	  
});


function addFinanciealProduct(){
	var formData = $("#financialProduct").serializeObject();
	<c:url var="addFinancial" value="/finance/add" />
	var params={url:"${addFinancial}",success:onSuccess,data:formData,type:"POST",dataType:"json"};
	doAjax(params);
}

function onSuccess(result)
{
	console.log(result);
	console.log(result.objectName);
 	$("input[name='"+result.objectName+"']").val(result.objectId);
 	$( result.fieldError).each(function() {
		$('input[name="'+this.field+'"]').css( "border",'1px solid red' );
	});
}



</script>

 
        